package cn.ekgc.scalademo1

object Demo1 extends App {

  /*var s = Set("ab","aaa", "yz")
  var t = Set("ab", "gh", "mn", "st", "yz" )
  //求交集
  println(t & s)


  println(t intersect s)
  //求并集
  println(t | s)
  t union s
  //求差集
  println(t &~ s)
  t diff s*/

 //var map =  Map()
 //map += "a" -> 11
  //println(map.getClass)


 //
 val line1 = "The Apache Hive ™ data warehouse software facilitates reading, writing, and managing large datasets residing in distributed storage using SQL. Structure can be projected onto data already in storage. A command line tool and JDBC driver are provided to connect users to Hive"

 val line2 = "i am student i am 17 i am boy"
 val arr = Array(line1,line2)
 arr.flatMap(line => line.split(" ")).foreach(println(_))
 //java String equals  indexOf  startWith endWith  replace replaceAll substring concat ...

 //1 分组 groupBy(value) value 就将来分完组的key
 //arr.groupBy(a => a) //k/v
 //2 聚合想法
 //val m:Map[String,Int] = Map()

// import scala.collection.mutable.{Map => MMap}
//
//
// def f1(map:MMap[String,Int],word:String):MMap[String,Int] = {
//  map += word -> (map.getOrElse(word,0)+1)
//  map
// }
//
// def f2(m:MMap[String,Int],w:String) = {
//  m += w -> (m.getOrElse(w,0)+1)
//  m
// }
//
// arr.foldLeft(MMap[String,Int]())((m,w) => {
//  m += w -> (m.getOrElse(w,0)+1)
//  m
// }).foreach(println(_))






}
